<?php
session_start();
$order_user = $_SESSION['userid'];
date_default_timezone_set('prc');

$tableOrder = "orderlist";

 
$admin_keywordes = $_REQUEST['keywordes'];




$admin_year = date('Y');
$admin_month = date('m');
$admin_days = date('d');


$hour = date('H');


 
if($hour<10)
{$admin_ats=1;}
else if((10<=$hour)and($hour<=15))
{$admin_ats=2;}
else
{$admin_ats=3;}

	
$searchStr = $admin_year."年".$admin_month."月".$admin_days."日";




//更改订餐状态

if($admin_keywordes)
{
$sql = "update orderlist set search_status= search_status+1 where (order_date='$searchStr' and order_at='$admin_ats' and user_id
='$admin_keywordes')";
$query = mysql_query($sql) or die ("修改就餐状态失败");
}


//计算订餐人总数
$query = mysql_query("SELECT COUNT(distinct(user_id))  FROM orderlist where (order_date = '$searchStr' and order_at='$admin_ats')");
$order_sum = mysql_result($query, 0);


//计算已经就餐的人数
$query = mysql_query("SELECT COUNT(distinct(user_id)) FROM orderlist where order_date = '$searchStr' and search_status != '0' and order_at='$admin_ats' ");
$order_sum_ed = mysql_result($query, 0);



        //$reStr = $admin_year."年".$admin_month."月".$admin_days."日 ".$admin_ats_str;
		
        $query = mysql_query("select count(nid) from $tableOrder where (order_date='$searchStr' and order_at='$admin_ats' and user_id ='$admin_keywordes')");
     
		
        //$result = mysql_query("select * from $tableOrder where (order_date='$searchStr' and order_at='$admin_ats') order by nid");
        $result = mysql_query("select * from $tableOrder where (order_date='$searchStr' and order_at='$admin_ats' and user_id ='$admin_keywordes') order by nid");
     
	
	
    $sum = mysql_result($query, 0);
	
	
    while ($row = mysql_fetch_array($result)) {
        $search_name[] = $row['product_name'];
        $search_id[] = $row['product_id'];
        $search_date[] = $row['order_date'];
        $search_num[] = $row['product_num'];
        $search_at[] = $row['order_at'];
        $search_user[] = $row['user_id'];
        $search_user_name[] = $row['user_name'];
        $search_one_price[] = $row['product_price'];
        $search_price[] = $row['order_price'];
		$search_status[] = $row['search_status'];
		
    }
 


?>